package com.imau.servlet;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;

@WebServlet("/servletA")
public class ServletA extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("ServletA...");

        //获取session
        HttpSession session = request.getSession();

        //存储数据
        session.setAttribute("username","admin");


        //销毁session
        //session.invalidate();
        System.out.println(session.getId());
    }
}
